﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.Data;
using Newtonsoft.Json.Linq;
using System.Net;

namespace Test_API
{
    class LearningMaterialTest : GenericModuleTest
    {
        protected override string moduleName
        {
            get
            {
                return "Learning Materials";
            }
        }
        public LearningMaterialTest(string accessToken, string cid, string projectFolder)
            : base(accessToken)
        {
            this.viewAllMethod = "viewAllLearningMaterials";
            this.viewSingleItemMethod = "viewLearningMaterial";
            this.deleteMethod = "deleteLearningMaterial";
            this.cid = cid;
            this.uploadMethod = "uploadInLearningMaterials";
            this.projectFolder = projectFolder;
        }

        protected override string genericQueryStringGenerate(int testId)
        {
            string queryString = new Dictionary<string, string>() { { "cid", this.cid }, { "accesstoken", this.accesstoken }, { "itemid", testId.ToString() } }.buildQueryString();

            return queryString;
        }
        protected override Dictionary<string, object> genericPostDataSetGenerate()
        {
            throw new NotImplementedException();
        }
    
        public List<LogEntry> start(string localFile)
        {
            Console.WriteLine("Learning Materials API call begin\n============");
            List<LogEntry> entries = new List<LogEntry>();

            entries.AddRange(this.uploadFile(localFile, 0, this.uploadMethod));
            entries.AddRange(this.viewAll());
            entries.AddRange(this.viewSingle());
            entries.AddRange(this.createFolder(0));
            entries.AddRange(this.downloadFile());
            entries.AddRange(this.delete());
            
            return entries;
        }
    }
}
